<?php

/*
 * @copyright :     Ienter asia Technologies
 * @author :        Quyet
 * @version         v.1.0
 * @created         12/8/2014
 * @Description :   Controller Position
 */
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Mod_position extends MYAD_Controller {

    function __construct() {
        parent::__construct();
        $this->load->model('Mmod_position', 'po');
    }

    function index($page = 0) {
        $data = $this->po->getAllData($page);
        $this->load->view('layout', $data);
    }

    function updatePosition() {
        /* check exists */
        $positionID = $this->input->post('txtPositionID');
        $positions = TRUE;
        if ($positionID) {
            $positions = $this->po->countPositionByID($positionID);
        }
        if (!$positions) {
            redirect('/position');
        }
        $temp = array();
        if (isset($_POST['btnSubmit'])) {
            $validateFlag = $this->po->validate();
            if ($validateFlag) {
                /* validate success */
                $temp = $this->po->updatePosition($positionID);
            }
        }
        $data = $this->po->getAddPosition($positionID);
        $this->load->view('layout', array_merge($data, $temp));
    }

}

?>